<template>
	<view>
		
		<view class="" v-for="(item,index) in orders" :key="index" style="width: 100%;">
			<view class="" style="display: flex;padding: 20rpx;">
				<view class="" style="flex: 1;width: 300rpx;">
					<image :src="item.img" mode="" style="width: 300rpx;height: 200rpx;border-radius: 20rpx;"></image>
				</view>
				<view class="" style="flex: 3;padding: 20rpx;font-size: 30rpx;">
					<view style="color: #0285ff;font-weight: bold;">{{item.title}}</view> 
					<view style="color: #8F8F94;">数量{{item.num}}张</view> 
					<view style="color: #8F8F94;">{{item.people}}</view>
					<view style="color: #0285ff;font-weight: bold;">￥{{item.price*item.num}}元</view>
				</view>
				<view class="" style="flex: 1;margin-top: 70rpx;">
					<u-button type="primary" size="mini" plain @click="del">退票</u-button>
				</view>
			</view>
			<u-modal v-model="show" :content="content" @confirm="move(item)"></u-modal>
		</view>
		
		<u-empty text="订单为空~" mode="order" :show="show1" margin-top="400"></u-empty>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				show1:true,
				orders:[],
				show:false,
				content:'您确定退票吗？',
				
			}
		},
		methods: {
			del(){
				this.show=true
			},
			move(x){
				this.orders.splice(this.orders.indexOf(x),1);
				// this.$store.state.userInfo.order.splice(this.$store.state.userInfo.order.indexOf(x),1)	
				// console.log(this.orders)
				if(this.orders.length!=0){
					this.show1=false
				}else{
					this.show1=true
				}
				// console.log(this.orders.length)
				this.$store.state.userInfo.order.splice(this.$store.state.userInfo.order.indexOf(x),1)
				uni.setStorage({
					key: 'userInfo',
					data: this.$store.state.userInfo,
					success: function () {
						// console.log('success');
					}
				});
			}
		},
		mounted(){
			let that=this
			
			uni.getStorage({
				key: 'userInfo',
				success: function (res) {
					that.orders=res.data.order
					if(that.orders.length!=0){
						that.show1=false
					}else{
						that.show1=true
					}
					// console.log(that.orders.length)
					// // that.show1=false
					// console.log(that.show1)
					// console.log(that.orders)
				},
				fail: (err) => {
					that.show1=true
					// console.log(that.show1)
				},
			});
		}
	}
</script>

<style>

</style>
